/*
Maria Abrajano	
Proposal title: Using Experiments to Estimate Racially Polarized Voting


HYPOTHESES

Stated-Hyp1: Candidate preferences will vary based on "inferences about whom to support based on racial signals, under conditions where voters have little other information about candidate ideology or political position." (p. 3)

	Test-Hyp1: There will be a difference in liklihood of selection of Latino vs. white candidates.
	
	// NOTE: there were no black candidates in the fielded quex.

Stated-Hyp2: "The treatment effects of substantive interest are: (1) the joint effect of switching race from "white" to "black" ("Latino") and endorsement from "placebo" to "NAACP" ("NCLR")..." (p. 3)

	// Can't test. There is no indicator of organizational endorsement.

Stated-Hyp3: "The treatment effects of substantive interest are ... (2) the conditional effect of switching race from "white" to "black" ("Latino"), conditional on the candidate having a political party endorsement." (p. 3)

	Test-Hyp2: There will be a difference in liklihood of selection of Latino vs. white candidates, controlling for whether or not the candidate has a political party endorsement.


Stated-Hyp4: "Linked fate" will be a moderator of the above effects. i.e. there will be moderation by respondent race/ethnicity (p. 3)

	// Can't test. All respondents are white, Non-Hispanic.
	
********************************************************************************
NOTES:
- each respondent saw 6 vignettes. File needs to be reshaped by respondent id, 
and SE's will be clustered by respondent.

- Not sure what authors mean by "joint effect" in hypothesis 1. We are assuming 
it means changing both race+endorsement. However, we can't test this because 
endorsement information was not included.

- "Group stereotypes" is listed as a moderator on page 3. It is unclear how the 
authors planned to measure this. There are measures of whether the respondent 
thinks stereotypes are fine or not, but there is no measure of whether the 
respondent themselves have any negative stereotypes.

- The researcher requested sample stratified by respondents' race/ethnicity. 
However, in the fielded sample, all respondents are white, non-Hispanic. 
So we can't test stated hypotheseis 4 (varname PPETHM).
*/

clear all
use "Abrajano713.dta", clear

********************************************************************************
* INDICATORS OF EXPERIMENTAL MANIPULATIONS

* respodnent's race
	tab PPETHM // all white NH


* RESHAPE
	/* we want to create a file where each row is a unique question+panel+respondent
	This will result in 12 rows per respondent
	*/

	* first reshape by question
	keep CaseID Q1_CANDIDATEA_ETHNICITY Q1_CANDIDATEB_ETHNICITY Q1_CANDIDATEA_POLITICALPARTY Q1_CANDIDATEB_POLITICALPARTY Q2_CANDIDATEA_ETHNICITY Q2_CANDIDATEB_ETHNICITY Q2_CANDIDATEA_POLITICALPARTY Q2_CANDIDATEB_POLITICALPARTY Q3_CANDIDATEA_ETHNICITY Q3_CANDIDATEB_ETHNICITY Q3_CANDIDATEA_POLITICALPARTY Q3_CANDIDATEB_POLITICALPARTY Q4_CANDIDATEA_ETHNICITY Q4_CANDIDATEB_ETHNICITY Q4_CANDIDATEA_POLITICALPARTY Q4_CANDIDATEB_POLITICALPARTY Q5_CANDIDATEA_ETHNICITY Q5_CANDIDATEB_ETHNICITY Q5_CANDIDATEA_POLITICALPARTY Q5_CANDIDATEB_POLITICALPARTY Q6_CANDIDATEA_ETHNICITY Q6_CANDIDATEB_ETHNICITY Q6_CANDIDATEA_POLITICALPARTY Q6_CANDIDATEB_POLITICALPARTY Q1 Q2 Q3 Q4 Q5 Q6 

	reshape long Q@_CANDIDATEA_ETHNICITY Q@_CANDIDATEB_ETHNICITY Q@_CANDIDATEA_POLITICALPARTY Q@_CANDIDATEB_POLITICALPARTY Q@, ///
	i(CaseID) j(qnum)

	* second by panel
	rename Q_CANDIDATEA_ETHNICITY ethnicity1
	rename Q_CANDIDATEB_ETHNICITY ethnicity2
	rename Q_CANDIDATEA_POLITICALPARTY party1
	rename Q_CANDIDATEB_POLITICALPARTY party2

	* create an id to uniquely identify person and question
	egen idq= concat(CaseID qnum)

	reshape long ethnicity party, i(idq) j(panelnum)

* Candidate race/ethnicity
	tab ethnicity

* candidate party endorsement
	tab party
	
	
* OUTCOME MEASURES

* selected or not
 	tab Q
	replace Q=. if Q==-1
	
	gen selected = 1 if Q == panelnum
	replace selected=0 if Q!=panelnum
	replace selected=. if Q==. // refusals
	tab selected, mis

********************************************************************************

* ANALYSIS

	
*	Test-Hyp1: There will be a difference in liklihood of selection of Latino vs. white candidates.
	reg selected i.ethnicity, vce(cluster CaseID)
	// do not reject. p=0.005
	tess 2.ethnicity, init(Abrajano713)
	
*	Test-Hyp2: There will be a difference in liklihood of selection of Latino vs. white candidates, controlling for whether or not the candidate has a political party endorsement.
	reg selected i.ethnicity i.party, vce(cluster CaseID)
	// do not reject. p=0.005	
	tess 2.ethnicity


